// React基础组件
import React from 'react'
// dva 连接组件 - 连接route和model
import { connect } from 'dva'
//导入路由组件，用于跳转等
import { Router, hashHistory, Link } from 'dva/router'
// 引入antd的组件
import {
  Tabs,
  Radio,
  Tooltip,
  Spin,
  Form,
  Table,
  Pagination,
  Popconfirm,
  Upload,
  Icon,
  message,
  Input,
  Select,
  Row,
  Col,
  Checkbox,
  Button,
  Modal,
  DatePicker,
  Tree,
  Badge,
} from 'antd'
// 判断对象是否为空
import { isEmpty, isArray, cloneDeep, set, get, pick } from 'lodash'
import CollapsiblePanels from 'widget/CollapsiblePanels/CollapsiblePanels'
// 引入列表页组件
import ListPage from 'widget/PageTmpl/ListPage'
// 引入model取值工具方法
import { mapStateToProps } from 'utils/view_utils'
// 当前组件样式
import Uploader from '../../../widget/Upload'
import styles from './advertisingListStyle.less'
import classnames from 'classnames/bind'
import moment from 'moment/moment'
import FlagBtn from 'widget/FlagBtn/FlagView'

let cx = classnames.bind(styles)
// 表单域
const FormItem = Form.Item
const TabPane = Tabs.TabPane
const TreeNode = Tree.TreeNode
const { RangePicker } = DatePicker
const RadioButton = Radio.Button
const RadioGroup = Radio.Group
const ButtonGroup = Button.Group
// 表单项布局
const formItemLayout = {
  // labelCol: {span: 5},
  // wrapperCol: {span: 18}
}
const formItemLayout01 = {
  labelCol: { span: 4 },
  wrapperCol: { span: 4 },
}
// url href hrefType title  slideshowId  published startDate   endDate    createPerson  createTime
let currentItem_default = {
  'url': '',
  'href': '',
  'type': 1,
  'ord': '1',
  'published': '0',
  'channel': '101',
  'title': '轮播图',
  'hrefType': '4',
  'slideshowId': '',
  'startDate': '',
  'endDate': '',
  // 'createPerson': '',
  // 'createTime': '',
  'params': {},
}
let hrefModalObj_default = {
  visible: false,
  hrefType: '4',
}
//专题活动mock数据
function getTopicList(channelIndex = '1') { //1美的置业云 2智美分销
  let rows = [
    {
      'id': '1',
      'title': '首页',
      'href': 'pages/biz/index/index',
    },
    {
      'id': '2',
      'title': '领优惠券',
      'href': 'pages/biz/my/myCoupons/couponsList/couponsList',
    },
    {
      'id': '3',
      'title': '我要推介',
      'href': 'pages/biz/recommend/recommend',
    },
    //  {
    //    'id': '4',
    //    'title': '双11秒杀专题',
    //    'href': 'pages/biz/kill/killHome/killHome',
    //  },
    //  {
    //    'id': '5',
    //    'title': '竞拍专题',
    //    'href': 'pages/biz/auctions/auction/auction',
    //  },
  ]

  if (channelIndex == '2') {
    rows = cloneDeep([rows[0]])
  }
  let toppicList = {
    // "pageNo": 1,
    'pageSize': 10,
    'rows': cloneDeep(rows),
    'success': true,
    // "total": 150
  }
  return toppicList
}


/*
1 楼盘 pages/biz/buildingDetail/buildingDetail?productId=1058340249522696192    productId
3 资讯 pages/biz/InformationDetail/InformationDetail?id=1069424887408910336  contentId
5 活动 pages/biz/findHouse/activity/apply/apply?contentId=&productId=   contentId   businessId
2 专题活动
领优惠券  pages/biz/my/myCoupons/couponsList/couponsList
首页  pages/biz/index/index
双11秒杀专题   pages/biz/kill/killHome/killHome
竞拍专题  pages/biz/auctions/auction/auction
我要推介 pages/biz/recommend/recommend
*/
function getHref(params) {
  console.log(params, 'key')
  let hrefMap = {
    1: {//楼盘
      hrefType: '1',
      hrefTypeName: '楼盘',
      href: `pages/biz/buildingDetail/buildingDetail?productId=${params.productId}`,
      title: `${params.name}`,
      query: 'productId',
      params: { key: params.productId }
    },
    2: {  //秒杀竞拍
      hrefType: '2',
      hrefTypeName: '秒杀竞拍',
      query: 'seckillActivityId',
      href: `${params.type == 1 ? 'pages/biz/kill/killHome/killHome' : 'pages/biz/auctions/auction/auction'}?seckillActivityId=${params.seckillActivityId}`,
      title: params.name,
      params: { key: params.seckillActivityId }
    },
    3: {  //资讯
      hrefType: '3',
      hrefTypeName: '资讯',
      href: `pages/biz/InformationDetail/InformationDetail?id=${params.contentId}`,
      title: `${params.title}`,
      query: 'id',
      params: { key: params.contentId }
    },
    4: {   //外部链接
      hrefType: '4',
      hrefTypeName: '外部链接',
      href: `${params.href}`,
      title: '轮播图',
      query: '',
      params: { key: params.href }
    },
    5: {   //活动
      hrefType: '5',
      hrefTypeName: '活动',
      // href: `pages/biz/findHouse/activity/apply/apply?contentId=${params.contentId}&productId=${params.productId}`,
      href: `pages/biz/findHouse/activity/apply/apply?contentId=${params.contentId}&productId=${params.businessId}`,
      title: `${params.title}`,
      query: 'contentId',
      params: { key: params.contentId }
    },
    6: {   //预约看房
      hrefType: '6',
      query: 'productId',
      hrefTypeName: '预约看房',
      title: params.name || params.btnName,
      // linkUrl: `/pages/biz/findHouse/activity/apply/apply?contentId=${params.contentId}&productId=${params.productId}`,
      href: `/pages/biz/makeAppointment/makeAppointment?productId=${params.productId}&mustRecommend=true`,
      params: { productId: params.productId }
    },
    7: {//推介
      hrefType: '7',
      hrefTypeName: '我要推介',
      href: `/pages/biz/recommend/recommend?productId=${params.productId}&mustRecommend=true`,
      params: { productId: params.productId },
      title: params.name || params.btnName,
      query: 'productId',
    },
    9: {  //专题活动
      hrefType: '9',
      hrefTypeName: '领优惠券',
      href: `${params.href}`,
      title: `${params.title}`,
      query: 'key',
      params: { key: params.id }
    },

  }

  let item = hrefMap[params.hrefType] || {}
  return item
}

// hrefType 链接类型(1:楼盘 2：专题活动 3：资讯 4:外部链接 5：活动)

const routeView = function ({ dispatch, model, form }) {
  // 取出model对象，命名空间
  const { modelObj, namespace, } = model
  let { bannerList = {}, newItemList = {}, writeUrl, nowUrlChange, pageInfo, pageNo, pageSize, currentItem = {}, status, mpUrlsObj, hrefType, channelIndex = '1', areaList, biz = {}, hrefModalObj = {},hitsModalObj } = modelObj
  const { resetFields, getFieldDecorator, validateFields, setFieldsValue, } = form
  console.log('modelObj', modelObj)
  currentItem.channel = channelIndex == 1 ? '101' : '201'
  hrefModalObj.channel = channelIndex == 1 ? '101' : '201'
  //当前列表
  let newItemList_cur = newItemList[channelIndex] || []
  let bannerList_cur = bannerList[channelIndex] || []
  let pageInfo_cur = pageInfo[channelIndex] || {}

  function inputchange(value = '', key = '', obj = {}, ) {
    set(obj, key, value, '')
    if (obj.slideshowId) {
      changeState({ bannerList })
    } else {
      changeState({ newItemList })
    }
  }

  //根据弹窗生成链接
  function setHref(hrefModalObj) {
    let obj = {}
    let { visible = false, hrefType = '4', idx = 0, slideshowId = '' } = hrefModalObj
    let hrefMap = {
      1: '',
      2: '',
      3: '',
      4: '',
    }

    return obj
  }

  //链接弹窗确定按钮
  const confirmHref = () => {
    let hrefInfo = {}
    let { visible = false, hrefType = '4', idx = 0, slideshowId = '' } = hrefModalObj
    hrefModalObj.visible = !visible
    // debugger
    // 判断类型，整合数据
    if (hrefType == '4') {
      if (!hrefModalObj.href.trim()) {
        message.warn('请输入链接')
        return false
      }
      hrefInfo = getHref(cloneDeep(hrefModalObj))
    } else {
      let selectedRows = (biz[hrefType] || {})['selectedRows'] || {}
      if (isEmpty(selectedRows)) {
        message.warn('请选择')
        return false
      }
      hrefInfo = getHref({ ...cloneDeep(hrefModalObj), ...cloneDeep(selectedRows[0]) })
    }
    hrefModalObj = { ...hrefModalObj, ...hrefInfo }
    if (slideshowId) {
      bannerList_cur[idx] = hrefModalObj
      changeState({ bannerList, hrefModalObj })
    } else {
      newItemList_cur[idx] = hrefModalObj
      changeState({ newItemList, hrefModalObj })

    }
    // validateFields(
    //   (err) => {
    //   },
    // )
  }

  //修改状态
  const changeState = (payload) => {
    console.log(payload)
    dispatch({
      type: `${namespace}/updateStore`,
      payload: { ...payload }
    })
  }

  //分页
  function onChangePage(pageNo, pageSize) {
    pageInfo[channelIndex].pageNo = pageNo
    pageInfo[channelIndex].pageSize = pageSize
    changeState({ pageInfo })
    dispatch({ type: `${namespace}/getBannerList`, payload: { channelIndex, pageNo: pageNo, pageSize: pageSize } })
    console.log(pageNo, pageSize)
  }

  // 批量保存
  function saveAll() { //如果有新增，批量新增或者修改，优先新增
    // debugger

    let msg = ''
    let msgArr = []
    let cbk = () => {
      resetFields()
    }
    // let arr =cloneDeep(newItemList_cur)
    // validateFields((err) => {
    //   if (err) {
    //     return false
    //   }
    // })

    (newItemList_cur || []).concat(bannerList_cur || []).map((item, index) => {
      let num = Number(pageInfo_cur.pageNo - 1) * Number(pageInfo_cur.pageSize)
      let idx = index
      item.hrefType = item.hrefType || '4'
      item.ord = num + index + 1
      msg = ''
      if (!item.url) {
        msg = '图片不能为空'
        msgArr.push(`图${index + 1}${msg}`)
      }
    })
    if (!isEmpty(msgArr)) {
      message.warning(msgArr.join(';'))
      return false
    }
    changeState({ btnLoading: true, loading: true })
    if (!isEmpty(newItemList_cur)) {
      dispatch({ type: `${namespace}/createBanner`, payload: { arr: cloneDeep(newItemList_cur), cbk, channelIndex } })
      return false
    }
    if (!isEmpty(bannerList_cur)) {
      dispatch({ type: `${namespace}/updateBanner`, payload: { arr: cloneDeep(bannerList_cur), cbk, channelIndex } })
    }
  }

  // 保存
  function saveItem(item = {}, index = '') {
    // let fieldsNames = []
    // let arr = newItemList_cur
    // if (index !== '') {
    //   arr= [{...newItemList_cur[index], index,}]
    // }

    // let item = getCurrentItem(index)
    console.log('saveItem', item, index)
    if (!item.url) {
      message.warn('图片不能为空')
      return false
    }
    validateFields([], (err) => {
      if (!err) {
        // debugger
        let cbk = () => {
          resetFields()
        }
        if (!item.slideshowId) {
          let arr = [{ ...item, index, }]
          cbk = () => {
            resetFields()
            newItemList[channelIndex].splice(index, 1)
          }
          item.btnLoading = true
          dispatch({ type: `${namespace}/createBanner`, payload: { arr, index, cbk, channelIndex } })
        }
        else if (item.slideshowId) {
          item.btnLoading = true
          dispatch({ type: `${namespace}/updateBanner`, payload: { arr: [{ ...item }], pageNo, pageSize, cbk, channelIndex } })
        }
      }
    })
  }

  //删除
  function delItem(item = {}, index) {
    if (!item.slideshowId) {
      newItemList_cur.splice(item.idx, 1)
      changeState({ newItemList })
      return false
    }
    else if (item.slideshowId) {
      item.btnLoading = true
      dispatch({
        type: `${namespace}/deleteBanner`,
        payload: { item, pageNo, pageSize, channelIndex }
      })
    }
  }

  function changeCurrentItem() {

  }


  // 分页表格属性配置 // hrefType 链接类型(1:楼盘 2：专题活动 3：资讯 4:外部链接 5：活动)
  let pageProps = {
    '6': {   //预约看房
      // ---------- 界面部分 ----------
      ui: {
        // 页面接口地址
        api_url: 'admin/estate/adminList',
        // 接口方式
        method: 'POST',
        headers: {
          'Content-type': 'application/json'
        },
        app: '',
        // 接口参数
        params: 'pageNo=1&pageSize=10&shelfStatus=1',
        // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
        // "mockData": mockData,
        mockData: null,
        // 查询栏
        search_bar: {
          fields: [
            {
              en_name: 'province',
              zh_name: '城市',
              elem_type: 'Cascader',
              elem_valid_type: 'string',
              changeOnSelect: true,
              cmpt_items: areaList,
              split_keys: ['province', 'city'],
            },
            {
              en_name: 'name',
              zh_name: '项目名称',
              elem_type: 'Input',
              elem_valid_type: 'string',
            },
          ],

          pasteTargetList: [  // 列表组件中将输入框的en_name作为默认id(也可以通过id另外设置)
            'carName',  // 将需要粘贴事件拦截的输入框id以数组的形式传入, 该参数对应PasteFromClipboard组件的targetList参数
          ]
        },
        // 数据表格
        'table':
        {
          rowSelectionInfo: {
            type: 'radio',
          },
          key: 'productId',
          status_params: 'status=0',
          status_text: '全部',
          // 表头字段列表
          scroll: { x: 800 },
          fields: [
            {
              en_name: 'estateCode',
              zh_name: '项目编号',
              // width: 150,
            },
            {
              en_name: 'name',
              zh_name: '项目名称',
              // width: 100,
            },
            {
              en_name: 'cityName',
              zh_name: '所属城市',
              width: 150,
              // width: 100,
              render: (a, item, index, d, e, f) => {
                //console.log(item)
                let arr = ['北京市', '重庆', '上海', '天津']
                if (arr.indexOf(item.provinceName) > -1) {
                  return item.cityName
                } else {
                  return `${item.provinceName || ''}${item.provinceName && item.cityName && ' - ' || ''}${item.cityName || ''}`
                }

              }
            },
            {
              en_name: 'shelfStatus',
              zh_name: '状态',
              width: 80,
              render: (a, item, index, d, e, f) => {
                let shelfStatus = ['', '已上架', '已下架', '未上架']
                return (
                  <span>{shelfStatus[item.shelfStatus]}</span>
                )
              }
            },
            {
              en_name: 'createPerson',
              zh_name: '创建人',
              // width: 100,
            },
            {
              en_name: 'createTime',
              zh_name: '创建时间',
              width: 180
            },
          ],
          // 表格操作
          actions: [],
        },
        action_bar: [
          {
            // label:'',
            // type:'',
            rowSelection: [],
            render: () => {
              return <Input hidden />
            },
            onClick: (e, row) => {
              console.log(e, row)
            }
          },
        ]
      },
    },
    '7': {   //我要推介
      // ---------- 界面部分 ----------
      ui: {
        // 页面接口地址
        api_url: 'admin/estate/adminList',
        // 接口方式
        method: 'POST',
        headers: {
          'Content-type': 'application/json'
        },
        app: '',
        selectedRowKeys: [],
        // 接口参数
        params: 'pageNo=1&pageSize=10&shelfStatus=1',
        // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
        // "mockData": mockData,
        mockData: null,
        // 查询栏
        search_bar: {
          fields: [
            {
              en_name: 'province',
              zh_name: '城市',
              elem_type: 'Cascader',
              elem_valid_type: 'string',
              changeOnSelect: true,
              cmpt_items: areaList,
              split_keys: ['province', 'city'],
            },
            {
              en_name: 'name',
              zh_name: '项目名称',
              elem_type: 'Input',
              elem_valid_type: 'string',
            },
          ],

          pasteTargetList: [  // 列表组件中将输入框的en_name作为默认id(也可以通过id另外设置)
            'carName',  // 将需要粘贴事件拦截的输入框id以数组的形式传入, 该参数对应PasteFromClipboard组件的targetList参数
          ]
        },
        // 数据表格
        'table':
        {
          rowSelectionInfo: {
            type: 'radio',
          },

          key: 'productId',
          status_params: 'status=0',
          status_text: '全部',
          // 表头字段列表
          scroll: { x: 800 },
          fields: [
            {
              en_name: 'productCode',
              zh_name: '项目编号',
              // width: 150,
            },
            {
              en_name: 'name',
              zh_name: '项目名称',
              // width: 100,
            },
            {
              en_name: 'cityName',
              zh_name: '所属城市',
              width: 150,
              // width: 100,
              render: (a, item, index, d, e, f) => {
                //console.log(item)
                let arr = ['北京市', '重庆', '上海', '天津']
                if (arr.indexOf(item.provinceName) > -1) {
                  return item.cityName
                } else {
                  return `${item.provinceName || ''}${item.provinceName && item.cityName && ' - ' || ''}${item.cityName || ''}`
                }

              }
            },
            {
              en_name: 'shelfStatus',
              zh_name: '状态',
              width: 80,
              render: (a, item, index, d, e, f) => {
                let shelfStatus = ['', '已上架', '已下架', '未上架']
                return (
                  <span>{shelfStatus[item.shelfStatus]}</span>
                )
              }
            },
            {
              en_name: 'createPerson',
              zh_name: '创建人',
              // width: 100,
            },
            {
              en_name: 'createTime',
              zh_name: '创建时间',
              width: 180
            },
          ],
          // 表格操作
          actions: [],
        },
        action_bar: [
          {
            // label:'',
            // type:'',
            rowSelection: [],
            render: () => {
              return <Input hidden />
            },
            onClick: (e, row) => {
              console.log(e, row)
            }
          },
        ]
      },
    },
    '1': {   //楼盘
      // ---------- 界面部分 ----------
      ui: {
        // 页面接口地址
        api_url: 'admin/estate/adminList',
        // 接口方式
        method: 'POST',
        headers: {
          'Content-type': 'application/json'
        },
        app: '',
        // 接口参数
        params: 'pageNo=1&pageSize=10&shelfStatus=1',
        // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
        // "mockData": mockData,
        mockData: null,
        // 查询栏
        search_bar: {
          fields: [
            {
              en_name: 'province',
              zh_name: '城市',
              elem_type: 'Cascader',
              elem_valid_type: 'string',
              changeOnSelect: true,
              cmpt_items: areaList,
              split_keys: ['province', 'city'],
            },
            {
              en_name: 'name',
              zh_name: '项目名称',
              elem_type: 'Input',
              elem_valid_type: 'string',
            },
            // {
            //   en_name: 'shelfStatus',
            //   zh_name: '状态',
            //   elem_type: 'Select',
            //   cmpt_items: [
            //     {value: null, label: '全部'},
            //     {value: '0', label: '未上架'},
            //     {value: '1', label: '已上架'},
            //     {value: '2', label: '已下架'},
            //   ],
            //   elem_valid_type: 'string',
            // },
          ],
          searchHandler: (e) => { // 自定义搜索按钮回调函数，点击搜索时触发
            console.log('search click', e)
          },
          resetHandler: () => { // 自定义重置按钮回调函数，点击重置时触发
            console.log('reset click')
          },
          searchCallback: params => { // 自定义搜索完成后的后调函数, 搜索完成后触发, 并将本次搜索的参数传入
            console.log('search finish', params)
          },
          pasteTargetList: [  // 列表组件中将输入框的en_name作为默认id(也可以通过id另外设置)
            'carName',  // 将需要粘贴事件拦截的输入框id以数组的形式传入, 该参数对应PasteFromClipboard组件的targetList参数
          ]
        },
        // 数据表格
        'table':
        {
          rowSelectionInfo: {
            type: 'radio',
          },
          key: 'productId',
          status_params: 'status=0',
          status_text: '全部',
          // 表头字段列表
          scroll: { x: 800 },
          fields: [
            {
              en_name: 'estateCode',
              zh_name: '项目编号',
              // width: 150,
            },
            {
              en_name: 'name',
              zh_name: '项目名称',
              // width: 100,
            },
            {
              en_name: 'cityName',
              zh_name: '所属城市',
              width: 150,
              // width: 100,
              render: (a, item, index, d, e, f) => {
                //console.log(item)
                let arr = ['北京市', '重庆', '上海', '天津']
                if (arr.indexOf(item.provinceName) > -1) {
                  return item.cityName
                } else {
                  return `${item.provinceName || ''}${item.provinceName && item.cityName && ' - ' || ''}${item.cityName || ''}`
                }

              }
            },
            {
              en_name: 'shelfStatus',
              zh_name: '状态',
              width: 80,
              render: (a, item, index, d, e, f) => {
                let shelfStatus = ['未上架', '已上架', '已下架']
                return (
                  <span>{shelfStatus[item.shelfStatus]}</span>
                )
              }
            },
            {
              en_name: 'createPerson',
              zh_name: '创建人',
              // width: 100,
            },
            {
              en_name: 'createTime',
              zh_name: '创建时间',
              width: 180
            },
          ],
          // 表格操作
          actions: [],
        },
        action_bar: [
          {
            // label:'',
            // type:'',
            rowSelection: [],
            render: () => {
              return <Input hidden />
            },
            onClick: (e, row) => {
              console.log(e, row)
            }
          },
        ]
      },
    },
    '2': {   //专题活动
      // ---------- 界面部分 ----------
      ui: {
        // 页面接口地址
        // api_url: "",
        api_url: 'admin/seckillActivity/advertList',
        method: 'POST',
        headers: {
          'Content-type': 'application/json'
        },
        app: '',
        // 接口参数
        params: 'published=2',
        // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
        // "mockData": mockData,
        mockData: null,
        search_bar: {
          fields: [
            {
              en_name: 'province',
              zh_name: '省市',
              elem_type: 'Cascader',
              elem_valid_type: 'string',
              cmpt_items: areaList,
              split_keys: ['province', 'city'],
              //关联的更改的搜索字段
              related_key: 'businessId',
              //请求地址
              related_req_url: 'admin/estate/adminList',
              //默认请求
              related_req_param: {
                pageNo: 1,
                pageSize: 1000
              }
            },
            {
              en_name: 'businessId',
              zh_name: '项目名称',
              elem_type: 'Select',
              elem_valid_type: 'string',
              cmpt_items: []
            },
            {
              en_name: 'sellType',
              zh_name: '活动类型',
              elem_type: 'Select',
              elem_valid_type: 'string',
              cmpt_items: [{ value: 1, label: '秒杀' }, { value: 2, label: '竞拍' }]
            },
            // {
            //   en_name: 'title',
            //   zh_name: '资讯标题',
            //   elem_type: 'Input',
            //   elem_valid_type: 'string',
            // }

          ],
          pasteTargetList: [  // 列表组件中将输入框的en_name作为默认id(也可以通过id另外设置)
            'channel',  // 将需要粘贴事件拦截的输入框id以数组的形式传入, 该参数对应PasteFromClipboard组件的targetList参数
          ]
        },
        // 数据表格
        'table':
        {
          rowSelectionInfo: {
            type: 'radio',
          },
          key: 'seckillActivityId',
          status_params: 'status=0',
          status_text: '全部',
          // 表头字段列表
          scroll: { x: 800 },
          fields: [
            {
              en_name: 'name',
              zh_name: '活动名称',
            },
            {
              en_name: 'type',
              zh_name: '活动类型',
              render: (text) => {
                return (
                  <span>{['', '秒杀', '竞拍'][text]}</span>
                )
              }
            },
            {
              en_name: 'productNames',
              zh_name: '所属项目',
            },
            {
              en_name: 'productCitys',
              zh_name: '所属城市',
            },
          ],
          // 表格操作
          actions: [],
          pagination: {

          },
        },
        action_bar: [
          {
            // label:'',
            // type:'',
            rowSelection: [],
            render: () => {
              return <Input hidden />
            },
            onClick: (e, row) => {
              console.log(e, row)
            }
          },
        ]
      },
    },
    '9': {   //专题活动
      // ---------- 界面部分 ----------
      ui: {
        // 页面接口地址
        // api_url: "",
        api_url: '',
        // 接口方式
        method: 'POST',
        // "data_field_name":"data",
        app: '',
        // 接口参数
        params: '',
        // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
        // "mockData": mockData,
        mockData: cloneDeep(getTopicList(channelIndex)),
        // 数据表格
        'table':
        {
          rowSelectionInfo: {
            type: 'radio',
          },
          key: 'id',
          status_params: 'status=0',
          status_text: '全部',
          // 表头字段列表
          scroll: { x: 800 },
          fields: [
            {
              en_name: 'title',
              zh_name: '标题',
            },
            {
              en_name: 'href',
              zh_name: '链接',
            },
          ],
          // 表格操作
          actions: [],
        },
        action_bar: [
          {
            // label:'',
            // type:'',
            rowSelection: [],
            render: () => {
              return <Input hidden />
            },
            onClick: (e, row) => {
              console.log(e, row)
            }
          },
        ]
      },
    },
    '3': {  //资讯
      // ---------- 界面部分 ----------
      ui: {
        // 页面接口地址
        api_url: 'admin/news/list',
        // 接口方式
        method: 'POST',
        // "data_field_name":"data",
        app: '',
        // 接口参数
        params: 'channel=1',
        // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
        // "mockData": mockData,
        mockData: null,
        search_bar: {
          fields: [
            {
              en_name: 'province',
              zh_name: '省市',
              elem_type: 'Cascader',
              elem_valid_type: 'string',
              cmpt_items: areaList,
              split_keys: ['province', 'city'],
              //关联的更改的搜索字段
              related_key: 'businessId',
              //请求地址
              related_req_url: 'admin/estate/adminList',
              //默认请求
              related_req_param: {
                pageNo: 1,
                pageSize: 1000
              }
            },
            {
              en_name: 'businessId',
              zh_name: '项目名称',
              elem_type: 'Select',
              elem_valid_type: 'string',
              cmpt_items: []
            },
            {
              en_name: 'title',
              zh_name: '资讯标题',
              elem_type: 'Input',
              elem_valid_type: 'string',
            }
            // {
            //   en_name: 'channel',
            //   zh_name: '资讯类型',
            //   elem_type: 'Select',
            //   elem_valid_type: 'string',
            //   cmpt_items: [
            //     {
            //       value: '1',
            //       label: '动态资讯'
            //     },
            //     {
            //       value: '3',
            //       label: '活动报名'
            //     }
            //   ],
            // }
          ],
          searchHandler: () => { // 自定义搜索按钮回调函数，点击搜索时触发
            console.log('search click')
          },
          resetHandler: () => { // 自定义重置按钮回调函数，点击重置时触发
            console.log('reset click')
          },
          searchCallback: params => { // 自定义搜索完成后的后调函数, 搜索完成后触发, 并将本次搜索的参数传入
            console.log('search finish', params)
          },
          pasteTargetList: [  // 列表组件中将输入框的en_name作为默认id(也可以通过id另外设置)
            'channel',  // 将需要粘贴事件拦截的输入框id以数组的形式传入, 该参数对应PasteFromClipboard组件的targetList参数
          ]
        },
        // 数据表格
        'table':
        {
          rowSelectionInfo: {
            type: 'radio',
          },
          key: 'contentId',
          status_params: 'status=0',
          status_text: '全部',
          // 表头字段列表
          scroll: { x: 800 },
          fields: [
            {
              en_name: 'title',
              zh_name: '资讯标题',
              width: 180
            },
            // {
            //   en_name: 'cityName',
            //   zh_name: '所属城市',
            //   // width: 100,
            //   render: (a, item, index, d, e, f) => {
            //     //console.log(item)
            //     let arr = ['北京市', '重庆', '上海', '天津']
            //     if (arr.indexOf(item.provinceName) > -1) {
            //       return item.cityName
            //     } else {
            //       return item.provinceName + item.cityName
            //     }
            //
            //   }
            // },
            {
              en_name: 'channel',
              zh_name: '资讯类型',
              width: 100,
              render: (a, item, index, d, e, f) => {
                if (item.channel == 1) {
                  item.channel = '动态资讯'
                } else if (item.channel == 3) {
                  item.channel = '活动报名'
                }
                return (
                  <span>{item.channel}</span>
                )
              }
            },
            {
              en_name: 'businessName',
              zh_name: '项目名称',
            },
            {
              en_name: 'createTime',
              zh_name: '更新时间',
              width: 360
            },
          ],
          // 表格操作
          actions: [],
        },
        action_bar: [
          {
            // label:'',
            // type:'',
            rowSelection: [],
            render: () => {
              return <Input hidden />
            },
            onClick: (e, row) => {
              console.log(e, row)
            }
          },
        ]
      },
    },
    '5': {  //活动
      // ---------- 界面部分 ----------
      ui: {
        // 页面接口地址
        api_url: 'admin/news/list',
        // 接口方式
        method: 'POST',
        // "data_field_name":"data",
        app: '',
        // 接口参数
        params: 'channel=3',
        // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
        // "mockData": mockData,
        mockData: null,
        search_bar: {
          fields: [
            {
              en_name: 'province',
              zh_name: '省市',
              elem_type: 'Cascader',
              elem_valid_type: 'string',
              cmpt_items: areaList,
              split_keys: ['province', 'city'],
              //关联的更改的搜索字段
              related_key: 'businessId',
              //请求地址
              related_req_url: 'admin/estate/adminList',
              //默认请求
              related_req_param: {
                pageNo: 1,
                pageSize: 1000
              }
            },
            {
              en_name: 'businessId',
              zh_name: '项目名称',
              elem_type: 'Select',
              elem_valid_type: 'string',
              cmpt_items: []
            },
            {
              en_name: 'title',
              zh_name: '资讯标题',
              elem_type: 'Input',
              elem_valid_type: 'string',
            }
            // {
            //   en_name: 'channel',
            //   zh_name: '资讯类型',
            //   elem_type: 'Select',
            //   elem_valid_type: 'string',
            //   cmpt_items: [
            //     {
            //       value: '1',
            //       label: '动态资讯'
            //     },
            //     {
            //       value: '3',
            //       label: '活动报名'
            //     }
            //   ],
            // }
          ],
          searchHandler: () => { // 自定义搜索按钮回调函数，点击搜索时触发
            console.log('search click')
          },
          resetHandler: () => { // 自定义重置按钮回调函数，点击重置时触发
            console.log('reset click')
          },
          searchCallback: params => { // 自定义搜索完成后的后调函数, 搜索完成后触发, 并将本次搜索的参数传入
            console.log('search finish', params)
          },
          pasteTargetList: [  // 列表组件中将输入框的en_name作为默认id(也可以通过id另外设置)
            'channel',  // 将需要粘贴事件拦截的输入框id以数组的形式传入, 该参数对应PasteFromClipboard组件的targetList参数
          ]
        },
        // 数据表格
        'table':
        {
          rowSelectionInfo: {
            type: 'radio',
          },
          key: 'contentId',
          status_params: 'status=0',
          status_text: '全部',
          // 表头字段列表
          scroll: { x: 800 },
          fields: [
            {
              en_name: 'title',
              zh_name: '标题',
              width: 180
            },
            // {
            //   en_name: 'cityName',
            //   zh_name: '所属城市',
            //   // width: 100,
            //   render: (a, item, index, d, e, f) => {
            //     //console.log(item)
            //     let arr = ['北京市', '重庆', '上海', '天津']
            //     if (arr.indexOf(item.provinceName) > -1) {
            //       return item.cityName
            //     } else {
            //       return item.provinceName + item.cityName
            //     }
            //
            //   }
            // },
            {
              en_name: 'channel',
              zh_name: '类型',
              width: 100,
              render: (a, item, index, d, e, f) => {
                if (item.channel == 1) {
                  item.channel = '动态资讯'
                } else if (item.channel == 3) {
                  item.channel = '活动报名'
                }
                return (
                  <span>{item.channel}</span>
                )
              }
            },
            {
              en_name: 'businessName',
              zh_name: '项目名称',
            },
            {
              en_name: 'createTime',
              zh_name: '更新时间',
              width: 360
            },
          ],
          // 表格操作
          actions: [],
        },
        action_bar: [
          {
            // label:'',
            // type:'',
            rowSelection: [],
            render: () => {
              return <Input hidden />
            },
            onClick: (e, row) => {
              console.log(e, row)
            }
          },
        ]
      },
    },
    '10': {  //点击量用户列表
      // ---------- 界面部分 ----------
      ui: {
        // 页面接口地址
        api_url: 'admin/slideshow/browseUser',
        // 接口方式
        method: 'POST',
        // "data_field_name":"data",
        app: '',
        // 接口参数
        params: 'pageNo=1&pageSize=10',
        // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
        // "mockData": mockData,
        mockData: null,
        // 数据表格
        'table':
        {
          // rowSelectionInfo: {
          //   type: 'radio',
          // },
          // key: 'contentId',
          status_params: 'status=0',
          status_text: '全部',
          // 表头字段列表
          scroll: { x: 800 },
          fields: [
            {
              en_name: 'wxName',
              zh_name: '昵称',
              width: 100
            },
            {
              en_name: 'mobile',
              zh_name: '手机号',
              width: 130
            },
            {
              en_name: 'role',
              zh_name: '身份类型',
              width: 100
            },
            {
              en_name: 'cityName',
              zh_name: '所属城市',
              render: (a, item, index, d, e, f) => {
                let arr = ['北京市', '重庆', '上海', '天津']
                if (item.province && item.city) {
                  if (arr.indexOf(item.province) > -1) {
                    return item.city
                  } else {
                    return item.province + item.city
                  }
                }


              },
              width: 120
            },
            {
              en_name: 'street',
              zh_name: '详细地址',
            },
            {
              en_name: 'createTime',
              zh_name: '浏览时间',
              width: 180
            },
          ],
          // 表格操作
          actions: [],
        },
        action_bar: [
          {
            // label:'',
            // type:'',
            // rowSelection: [],
            render: () => {
              return <Input hidden />
            },
            onClick: (e, row) => {
              console.log(e, row)
            }
          },
        ]
      },
    },
  };
  // hrefType 链接类型(1:楼盘 2：专题活动 3：资讯 4:外部链接 5：活动)
  (['1', '2', '3', '5', '6', '7', '9', '10']).map((item, index) => {
    let _biz = biz[item + '']
    if (!!_biz) {
      pageProps[item + ''].biz = _biz
      pageProps[item + ''].biz.syncBackCbf = (newbiz) => {
        biz[item + ''] = newbiz
        dispatch({
          type: `${namespace}/updateStore`,
          payload: { biz }
        })
      }
    }
  })

  // 打开关闭设置链接弹窗
  function updateModal(flag = false, obj = {}) {
    let visible = flag
    hrefModalObj.visible = flag
    if (!visible) { //关闭
      changeState({ hrefModalObj, })
      return false
    }
    resetFields(['new_href'])
    if (!isEmpty(obj)) {
      hrefModalObj = { ...cloneDeep(hrefModalObj_default), ...cloneDeep(obj), visible }
      if (hrefModalObj.hrefType != '4') {
        (biz[hrefModalObj.hrefType] || {})['selectedRowKeys'] = [obj.params && obj.params.key || '']
      }
    } else {
      hrefModalObj = { ...cloneDeep(hrefModalObj_default), visible }
      currentItem = { ...cloneDeep(obj) }
    }
    changeState({ hrefModalObj, currentItem, biz })
  }
  //打开关闭查看用户列表弹窗
  function updateHitsModal(flag = false,obj = {},type){
    let checkNum = '10'
    let queryForm = biz[checkNum].queryForm
    biz[checkNum].queryForm = {...queryForm,
      slideshowId:obj
    }
    changeState({biz})
    let visible = flag.visible
    hitsModalObj.visible = flag
    // if(type === 'show' && biz['6'].refreshListDatas){
    //   biz['6'].refreshListDatas(true)
    // }
    if(!visible){ //关闭
      if(biz[checkNum].tableData){
        biz[checkNum].tableData.dataSource=[]
      }
      changeState({hitsModalObj,biz})
      return false
    }
    
  }
  function move(item, flag = 1) {
    let { idx, index = '' } = item || {}
    item = cloneDeep(item)
    let prev = cloneDeep(bannerList_cur[idx - 1] || {})
    let next = cloneDeep(bannerList_cur[idx + 1] || {})
    if (flag > 0) {
      bannerList_cur[idx] = next
      bannerList_cur[idx + 1] = item
    } else {
      bannerList_cur[idx] = prev
      bannerList_cur[idx - 1] = item
    }
    changeState({ bannerList })
  }
  function changeTab_modal(hrefType) {
    hrefModalObj.hrefType = hrefType
    changeState({ hrefModalObj })
    if (hrefType == 2) {
      // pageProps['2'].mockData=cloneDeep(getTopicList(channelIndex))
      biz['2'] && biz['2'].refreshListDatas(true)
    }
  }
  return <div className="public_listMain">
    <div className="functionButton">
      <FlagBtn
        node={<Button type="primary" htmlType="button" size="large" onClick={() => {
          resetFields()
          newItemList_cur.unshift(cloneDeep(currentItem_default))
          changeState({ newItemList })
          // openNewSave()
        }}>新增图片</Button>}
        btnId={'50201'}
      >
      </FlagBtn>

      <Button type="primary" htmlType="button" size="large" loading={modelObj.btnLoading} onClick={() => {
        // changeState({bannerList})
        saveAll()
      }}>批量保存{!isEmpty(newItemList_cur) ? '新增' : '修改'}</Button>
    </div>
    {/*切换tab*/}

    <Form>
      {/*首页banner设置*/}
      <CollapsiblePanels title="轮播图">
        <div className={cx('mgt1', 'mgb1')}>
          <i className="iconfont icon-ic_info_px"></i>
          <span>图片分辨率需为1372px*736px，且文件大小在200kb以下，支持jpg，png格式。</span>
        </div>

        <Tabs onChange={(channelIndex) => { changeState({ channelIndex }) }} type="card" activeKey={channelIndex}>
          <TabPane tab=" 美的置业云" key="1"></TabPane>
          <TabPane tab=" 智美分销" key="2"></TabPane>

        </Tabs>
        {/*美的置业云*/}
        {channelIndex == 1 &&
          <Row type="flex" gutter={16}>
            {
              ((newItemList['1'] || []).concat(bannerList['1'] || []) || []).map((item, index) => {
                let idx = index
                let obj = newItemList['1'] && newItemList['1'][index] || {}
                if (item.slideshowId) {
                  idx = index - newItemList['1'].length
                  obj = bannerList['1'][idx] || {}
                }
                obj.idx = idx
                obj.ord = index + 1
                return (
                  <Col xs={20} sm={20} md={20} lg={20} xl={12} className={'mgb2 '}
                    key={`item_1_${item.slideshowId || index || ''}`}>
                    <Spin spinning={obj.btnLoading || false}>
                      <div
                        className={cx('flex', 'flex_center_h', 'li', 'pdt1', 'pdb1', !item.slideshowId ? 'newItem' : '')}>
                        <Badge count={index + 1}
                          style={{ backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset' }}
                          className={cx('picNum')} />
                        {/*图片*/}
                        <div className={cx('imgBox')}>
                          <FormItem required={true} colon={false} key={'img_1' + index}>
                            <Uploader
                              uploadedUrls={item.url}
                              // imgUrlSize={'146'}
                              removeFileCbf={(e) => { inputchange('', `url`, obj) }}
                              uploadSuccessCbf={(imgUrl) => { inputchange(imgUrl, `url`, obj) }}
                              showType={'6'}
                              minCropBoxWidth={1372}
                              minCropBoxHeight={736}
                              fileType='image'
                              fileMaxSize='0.2'
                              maxFiles='1' />
                          </FormItem>
                        </div>

                        {/*内容 14*/}
                        <div style={{ position: 'relative', }} className={cx('item_content')}>
                          <div className={' pdr1'}>
                            <Row type={'flex'} gutter={8}>
                              <Col><span className={cx('key')}>跳转类型：</span> {{
                                1: '楼盘',
                                2: '秒杀竞拍',
                                3: '资讯',
                                4: '外部链接',
                                5: '活动',
                                6: '我要推介',
                                7: '预约看房',
                                9: '优惠券'
                              }[item.hrefType || ''] || ''}</Col>
                              <Col><span className={cx('key')}>名称：</span> {item.title || ''}</Col>
                            </Row>
                            <div type={'flex'} className={'flex'}>
                              <div className={cx('key')} style={{ minWidth: '70px' }}>跳转地址：</div>
                              <div className={cx('key')} span={16}>
                                <Tooltip placement="topLeft" title={item.href ? item.href : '暂无链接...'}>
                                  <a href='javascript:void(0);' className={cx('item_link', 'ellipsis ')}
                                    alt={item.href || ''}>{item.href ? item.href : '暂无链接...'}</a>
                                </Tooltip>
                              </div>

                            </div>
                            {/*
                        <Row type={'flex'}>
                          <Col className={cx('key')} style={{'lineHeight': '40px', minWidth: '70px'}}>序号： </Col>
                          <Col span={16}>
                            <FormItem {...formItemLayout} wrapperCol={{span: 8}}>
                              {getFieldDecorator((`ord_1_${item.slideshowId || index || ''}`), {
                                initialValue: item.ord,
                                rules: [
                                  {required: true, message: '请输入序号'},
                                  {pattern: /^[1-9]\d*$/, message: '请输入正确的数字'},
                                ],
                              })(<Input
                                placeholder='请输入序号'
                                onChange={(e) => {inputchange(Number(e.target.value), `ord`, obj) }}
                              />)}
                            </FormItem>
                          </Col>
                        </Row>
*/}
                            <Row type={'flex'}>
                              <Col className={cx('key')} style={{ 'lineHeight': '40px', minWidth: '70px' }}>有效时间： </Col>
                              <Col span={16}>
                                <FormItem {...formItemLayout} colon={false}>
                                  {getFieldDecorator((`date_1_${item.slideshowId || index || ''}`), {
                                    initialValue: item.date && [moment(item.date[0]), moment(item.date[1])] || null,
                                    rules: [
                                      { required: true, message: '请输入合作合同有效期', },
                                    ],
                                  })(<RangePicker
                                    required={true}
                                    placeholder={['开始时间', '结束时间']}
                                    allowClear={false}
                                    // value={item.date&&[moment(item.date[0]),moment(item.date[1])]||null}
                                    format="YYYY-MM-DD"
                                    onChange={(dates, dateStrings) => { inputchange(dateStrings, `date`, obj) }}
                                  />)}

                                  {/*<span style={{width: '40%'}} className="mgl1">到期后中介将不能登录</span>*/}
                                </FormItem>
                              </Col>
                            </Row>
                            <Row type={'flex'} gutter={16}>
                              <Col className={cx('status')}>
                                <span className={cx('key')}>状态：</span>
                                <RadioGroup defaultValue={item.published && (item.published + '') || '0'} size="small"
                                  className={cx('radio_p')}
                                  onChange={(e) => { inputchange(e.target.value, `published`, obj) }}
                                >
                                  <Radio style={{ display: 'inlineBlock' }} value="0">下架</Radio>
                                  <Radio style={{ display: 'inlineBlock' }} value="1">上架</Radio>
                                </RadioGroup>
                              </Col>
                              <Col><span className={cx('key')}>上传人</span>: {item.createPerson || ''}</Col>
                              <Col><span className={cx('key')}>上传时间</span>: {item.createTime || ''}</Col>
                            </Row>
                            <Row type={'flex'} >
                              <Col><span className={cx('key')}>点击量</span>: {item.browseCount || '0'}</Col>
                              <Col>
                                <a href='javascript:void(0);' className={cx('item_link', 'checkUserList')} onClick={() => { updateHitsModal(true, item.slideshowId) }}>查看用户列表</a>
                              </Col>
                            </Row>

                          </div>
                        </div>
                        {/*按钮*/}
                        <div className={cx('center', 'btns')}>
                          <div className="mgb1">
                            {/*<Button onClick={() => {updateModal(true, obj)}}>*/}
                            {/*{item.href ? '更改' : '添加'}链接*/}
                            {/*</Button>*/}
                            {item.href ? <FlagBtn
                              node={<Button onClick={() => { updateModal(true, obj) }}>
                                更改链接
                              </Button>}
                              btnId={'50202'}
                            >
                            </FlagBtn> : <Button onClick={() => { updateModal(true, obj) }}>
                                添加链接
                          </Button>}
                          </div>
                          <div className="mgb1">
                            {item.slideshowId &&
                              <FlagBtn
                                node={<Popconfirm placement="top" title={'确定删除当前广告轮播图吗？'} onConfirm={() => delItem(obj)} okText="确定" cancelText="取消">
                                  <Button>删除</Button>
                                </Popconfirm>}
                                btnId={'50203'}
                              >
                              </FlagBtn>
                            }

                            {!item.slideshowId &&
                              <Button onClick={() => delItem(obj)}>删除</Button>
                            }

                          </div>
                          {/*<div className="mgb1">*/}
                          {/*<Button type="primary" disabled={!item.url || !item.ord}*/}
                          {/*onClick={() => { saveItem(obj, index) }}>保存</Button>*/}
                          {/*</div>*/}
                          <div className={cx("mgb1", !item.slideshowId ? 'hidden' : '')} >
                            <ButtonGroup>
                              <Button type="default" title='上移' disabled={item.idx < 1} onClick={() => {
                                move(obj, -1)
                              }}>
                                <Icon type="arrow-up" />
                              </Button>
                              <Button type="default" title='上移' disabled={item.idx > bannerList['1'].length - 2} onClick={() => {
                                move(obj, 1)
                              }}>
                                <Icon type="arrow-down" />
                              </Button>
                            </ButtonGroup>
                          </div>
                        </div>
                      </div>
                    </Spin>
                  </Col>
                )
              })
            }
          </Row>
        }
        {/*智美分销*/}
        {channelIndex == 2 &&
          <Row type="flex" gutter={16}>
            {
              ((newItemList['2'] || []).concat(bannerList['2'] || []) || []).map((item, index) => {
                let idx = index
                let obj = newItemList['2'] && newItemList['2'][index] || {}
                if (item.slideshowId) {
                  idx = index - newItemList['2'].length
                  obj = bannerList['2'][idx] || {}
                }
                obj.idx = idx
                obj.ord = index + 1
                return (
                  <Col xs={20} sm={20} md={20} lg={20} xl={12} className={'mgb2 '}
                    key={`item_2_${item.slideshowId || index || ''}`}>
                    <div
                      className={cx('flex', 'flex_center_h', 'li', 'pdt1', 'pdb1', !item.slideshowId ? 'newItem' : '')}>
                      <Badge count={index + 1}
                        style={{ backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset' }}
                        className={cx('picNum')} />
                      {/*图片*/}
                      <div className={cx('imgBox')}>
                        <FormItem required={true} colon={false} key={'img_2' + index}>
                          <Uploader
                            uploadedUrls={item.url}
                            // imgUrlSize={'146'}
                            removeFileCbf={(e) => { inputchange('', `url`, obj) }}
                            uploadSuccessCbf={(imgUrl) => { inputchange(imgUrl, `url`, obj) }}
                            showType={'6'}
                            fileType='image'
                            fileMaxSize='0.2'
                            minCropBoxWidth={1372}
                            minCropBoxHeight={736}
                            maxFiles='1' />
                        </FormItem>
                      </div>

                      {/*内容 14*/}
                      <div style={{ position: 'relative', }} className={cx('item_content')}>
                        <div className={' pdr1'}>
                          <Row type={'flex'} gutter={8}>
                            <Col><span className={cx('key')}>跳转类型：</span> {{
                              1: '楼盘',
                              2: '秒杀竞拍',
                              3: '资讯',
                              4: '外部链接',
                              5: '活动',
                            }[item.hrefType || ''] || ''}</Col>
                            <Col><span className={cx('key')}>名称：</span> {item.title || ''}</Col>
                          </Row>
                          <div type={'flex'} className={'flex'}>
                            <div className={cx('key')} style={{ minWidth: '70px' }}>跳转地址：</div>
                            <div className={cx('key')} span={16}>
                              <Tooltip placement="topLeft" title={item.href ? item.href : '暂无链接...'}>
                                <a href='javascript:void(0);' className={cx('item_link', 'ellipsis ')}
                                  alt={item.href || ''}>{item.href ? item.href : '暂无链接...'}</a>
                              </Tooltip>
                            </div>

                          </div>
                          {/*
                        <Row type={'flex'}>
                          <Col className={cx('key')} style={{'lineHeight': '40px', minWidth: '70px'}}>序号： </Col>
                          <Col span={16}>
                            <FormItem {...formItemLayout} wrapperCol={{span: 8}}>
                              {getFieldDecorator((`ord_2_${item.slideshowId || index || ''}`), {
                                initialValue: item.ord,
                                rules: [
                                  {required: true, message: '请输入序号'},
                                  {pattern: /^[1-9]\d*$/, message: '请输入正确的数字'},
                                ],
                              })(<Input
                                placeholder='请输入序号'
                                onChange={(e) => {inputchange(Number(e.target.value), `ord`, obj) }}
                              />)}
                            </FormItem>
                          </Col>
                        </Row>
*/}
                          <Row type={'flex'}>
                            <Col className={cx('key')} style={{ 'lineHeight': '40px', minWidth: '70px' }}>有效时间： </Col>
                            <Col span={16}>
                              <FormItem {...formItemLayout} colon={false}>
                                {getFieldDecorator((`date_2_${item.slideshowId || index || ''}`), {
                                  initialValue: item.date && [moment(item.date[0]), moment(item.date[1])] || null,
                                  rules: [
                                    { required: true, message: '请输入合作合同有效期', },
                                  ],
                                })(<RangePicker
                                  required={true}
                                  placeholder={['开始时间', '结束时间']}
                                  allowClear={false}
                                  // value={item.date&&[moment(item.date[0]),moment(item.date[1])]||null}
                                  format="YYYY-MM-DD"
                                  onChange={(dates, dateStrings) => { inputchange(dateStrings, `date`, obj) }}
                                />)}

                                {/*<span style={{width: '40%'}} className="mgl1">到期后中介将不能登录</span>*/}
                              </FormItem>
                            </Col>
                          </Row>
                          <Row type={'flex'} gutter={16}>
                            <Col className={'flex'}>
                              <span className={cx('key')}>状态：</span>
                              <RadioGroup defaultValue={item.published && (item.published + '') || '0'} size="small"
                                className={cx('radio_p')}
                                onChange={(e) => { inputchange(e.target.value, `published`, obj) }}
                              >
                                <Radio style={{ display: 'inlineBlock' }} value="0">下架</Radio>
                                <Radio style={{ display: 'inlineBlock' }} value="1">上架</Radio>
                              </RadioGroup>
                            </Col>
                            <Col><span className={cx('key')}>上传人</span>: {item.createPerson || ''}</Col>
                            <Col><span className={cx('key')}>上传时间</span>: {item.createTime || ''}</Col>
                          </Row>
                        </div>
                      </div>
                      {/*按钮*/}
                      <div className={cx('center', 'btns')}>
                        <div className="mgb1">
                          <Button onClick={() => { updateModal(true, obj) }}>
                            {item.href ? '更改' : '添加'}链接
                        </Button>
                        </div>
                        <div className="mgb1">
                          {item.slideshowId &&
                            <Popconfirm placement="top" title={'确定删除当前广告轮播图吗？'} onConfirm={() => delItem(obj)}
                              okText="确定"
                              cancelText="取消">
                              <Button>删除</Button>
                            </Popconfirm>
                          }

                          {!item.slideshowId &&
                            <Button onClick={() => delItem(obj)}>删除</Button>
                          }

                        </div>
                        {/*<div className="mgb1">*/}
                        {/*<Button type="primary" disabled={!item.url || !item.ord}*/}
                        {/*onClick={() => { saveItem(obj, index) }}>保存</Button>*/}
                        {/*</div>*/}
                        <div className={cx("mgb1", !item.slideshowId ? 'hidden' : '')} >
                          <ButtonGroup>
                            <Tooltip placement="topLeft" title='上移'>
                              <Button type="default" disabled={item.idx < 1} onClick={() => {
                                move(obj, -1)
                              }}>
                                <Icon type="arrow-up" />
                              </Button>
                            </Tooltip>
                            <Tooltip placement="topLeft" title='下移'>
                              <Button type="default" disabled={item.idx > bannerList['2'].length - 2} onClick={() => {
                                move(obj, 1)
                              }}>
                                <Icon type="arrow-down" />
                              </Button>
                            </Tooltip>
                          </ButtonGroup>
                        </div>
                      </div>
                    </div>
                  </Col>
                )
              })
            }
          </Row>
        }

      </CollapsiblePanels>

      {/*分页*/}
      <Pagination onChange={onChangePage}
        style={{ textAlign: 'right', marginTop: '-15px', background: '#fff', padding: '16px' }}
        total={Number(pageInfo[channelIndex]['total'] || 0)} showSizeChanger showQuickJumper />

      {/*链接弹窗*/}
      <Modal
        visible={hrefModalObj.visible}
        onOk={confirmHref}
        onCancel={() => {
          updateModal(false)
        }}
        width={'80%'}
      >
        <div style={{ padding: '10px' }}>
          <div className={'mgb1'}>广告链接</div>
          <Form>
            <Tabs onChange={changeTab_modal} type="line" activeKey={hrefModalObj.hrefType + ''}>
              <TabPane tab=" 楼盘" key="1"></TabPane>
              {channelIndex == 1 && <TabPane tab="秒杀竞拍" key="2"></TabPane>}
              {channelIndex == 1 &&
                <TabPane tab=" 资讯" key="3"></TabPane>
              }
              {channelIndex == 1 &&
                <TabPane tab=" 活动" key="5"></TabPane>
              }
              {channelIndex == 1 &&
                <TabPane tab=" 我要推荐" key="6"></TabPane>
              }
              {channelIndex == 1 &&
                <TabPane tab=" 预约看房" key="7"></TabPane>
              }
              {channelIndex == 1 &&
                <TabPane tab="优惠券" key="9"></TabPane>
              }

              <TabPane tab=" 外部链接" key="4"></TabPane>
            </Tabs>

            {/*楼盘 1*/}
            {
              <div title="楼盘" className={cx(hrefModalObj.hrefType == '1' ? '' : 'hidden')}>
                <ListPage pageProps={pageProps['1']} />
              </div>
            }

            {/*秒杀竞拍 2*/}
            {
              <div title="秒杀竞拍" className={cx(hrefModalObj.hrefType == '2' ? '' : 'hidden')}>
                <ListPage pageProps={pageProps['2']} />
              </div>
            }

            {/*资讯 3*/}
            {
              <div title="资讯" className={cx(hrefModalObj.hrefType == '3' ? '' : 'hidden')}>
                <ListPage pageProps={pageProps['3']} />
              </div>
            }

            {/*外部链接 4*/}
            {
              <div className={cx(hrefModalObj.hrefType == '4' ? '' : 'hidden')}>
                <FormItem {...formItemLayout} label="跳转链接" hasFeedback>
                  {getFieldDecorator('new_href', {
                    initialValue: hrefModalObj.href || '',
                    // rules: [
                    //   { required: true, whitespace: true, message: `请输入正确链接`, pattern: /(http|ftp|https):\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ },
                    // ],
                  })(<Input
                    placeholder={'请输入链接'}
                    onChange={(e) => {
                      hrefModalObj.href = e.target.value
                      changeState({ hrefModalObj })
                    }}
                  />)}
                </FormItem>
              </div>
            }

            {/* 活动 5 */}
            {
              <div title="活动" className={cx(hrefModalObj.hrefType == '5' ? '' : 'hidden')}>
                <ListPage pageProps={pageProps['5']} />
              </div>
            }
            {
              <div title="我要推荐" className={cx(hrefModalObj.hrefType == '6' ? '' : 'hidden')}>
                <ListPage pageProps={pageProps['6']} />
              </div>
            }
            {
              <div title="预约看房" className={cx(hrefModalObj.hrefType == '7' ? '' : 'hidden')}>
                <ListPage pageProps={pageProps['7']} />
              </div>
            }
            {/*优惠券 9*/}
            {
              <div title="优惠券" className={cx(hrefModalObj.hrefType == '9' ? '' : 'hidden')}>
                <ListPage pageProps={pageProps['9']} />
              </div>
            }

          </Form>
        </div>
      </Modal>
      {/**点击用户列表弹窗 */}
      <Modal
        visible={hitsModalObj.visible}
        onOk={() => {
          updateHitsModal(false)
        }}
        onCancel={() => {
          updateHitsModal(false)
        }}
        footer={[<Button key="submit" type="primary"  onClick={()=>{updateHitsModal(false)}}>
         关闭
      </Button>]}
        destroyOnClose={true}
        width={'80%'}
        title='浏览用户列表'
      >
         <ListPage pageProps={pageProps['10']}/>  
       </Modal>

    </Form>

  </div>
}

// 连接视图(view)和模型(model)
export default connect(mapStateToProps)(Form.create()(routeView))
